<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 对象 -> 字符串
        // {name:"laowang",age:18} => name=laowang&age=18

        let obj = {name:"laowang",age:18,length:2,map:123}

    //    console.log(obj.map);

        // map数组方法
        // 对象 -> 数组 
        // key 数组 - 
        let arr =  Object.keys(obj);
        console.log(arr);

        let arr2 = arr.map(function(item){
            // console.log(item);
            return `${item}=${obj[item]}`;
        });

        let str = arr2.join('&');

        console.log(arr2);
        console.log(str);

        let str2 = Object.keys(obj).map(item=>`${item}=${obj[item]}`).join('&'); 

        console.log(str2);
        //value 数组
        // let arr2 = Object.values(obj);
        // console.log(arr2);


        // let str = '';
        // 对象循环
        // for(let item in obj){
        //     // console.log(obj[item]);
        //     console.log(item);
        //     // 属性值
        //     console.log(obj[item]);
        // }


    </script>
</body>
</html>